//
//  OrderDetailHeaderView.swift
//  Box
//
//  Created by mn on 2025/4/1.
//

import UIKit
import SnapKit

class OrderDetailHeaderView: UIView {
    
    private let backgroundImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.orderDetailHeaderBg
        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
        return imageView
    }()
    
    lazy var stateLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 23, weight: .semibold)
        label.textColor = .fromHex("#001C00")
        return label
    }()
    lazy var descLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 13, weight: .medium)
        label.textColor = .fromHex("#7D7D7D")
        label.lineBreakMode = .byTruncatingMiddle
        return label
    }()
    let addressView = AddressView()

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupUI()
    }
    
    private func setupUI() {
        backgroundColor = .fromHex("#F4F6F8")
        addSubview(backgroundImageView)
        addSubview(stateLabel)
        addSubview(descLabel)
        addSubview(addressView)
        addressView.layer.cornerRadius = 19
        backgroundImageView.snp.makeConstraints { make in
            make.edges.equalTo(UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0))
        }
        
        stateLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.centerY.equalToSuperview()
        }
        descLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.top.equalTo(stateLabel.snp.bottom).offset(5)
            make.width.equalTo(164)
        }
        addressView.snp.makeConstraints { make in
            make.left.equalToSuperview().inset(16)
            make.right.greaterThanOrEqualToSuperview().inset(16)
            make.bottom.equalToSuperview()
        }
        addressView.lineImageView.isHidden = true
    }
}
